package xuegao.study.mall.rbac.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import xuegao.study.mall.common.model.ums.UmsResourceCategory;
import xuegao.study.mall.rbac.service.UmsResourceCategoryService;
import xuegao.study.mall.repo.dao.ums.UmsResourceCategoryDao;

import java.util.Date;
import java.util.List;

@Service
public class UmsResourceCategoryServiceImpl implements UmsResourceCategoryService {
    @Autowired
    private UmsResourceCategoryDao umsResourceCategoryDao;

    @Override
    public List<UmsResourceCategory> listMenu() {
        return umsResourceCategoryDao.list();
    }

    @Override
    @Transactional
    public int add(UmsResourceCategory category) {
        category.setCreateTime(new Date());
        return umsResourceCategoryDao.insert(category);
    }

    @Override
    @Transactional
    public int update(Long id, UmsResourceCategory category) {
        category.setId(id);
        return umsResourceCategoryDao.update(category);
    }

    @Override
    @Transactional
    public int deleteById(Long id) {
        return umsResourceCategoryDao.deleteById(id);
    }
}
